<extend name="Public:base" />
<!-- 网站标题 -->
<block name="title">学校管理页面</block>
<block name="appendheader">
	<!-- Validform_v5.3.2验证框架 -->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Validform/css/Validform_v5.3.2.css"/>
	<script type="text/javascript" src="__PUBLIC__/Validform/js/Validform_v5.3.2_min.js"></script>
	
	<script type="text/javascript">
		$(function() {
			$("#WebMenu-2000").addClass('active');	//选中父菜单
			$("#WebMenu-3005").addClass('active');	//选中当前菜单
		});
	
		$(function() {
			var editor;
			var myform=$("#myform").Validform({
				tiptype:3,
				label:".label",
				showAllError:true,
				postonce:true,//开启二次提交防御
				ajaxPost:false,
				beforeSubmit:function(curform) {
					//在验证成功后，表单提交前执行的函数，curform参数是当前表单对象。
					lockScreen();
				},
				callback:function(data){
					$.Hidemsg();
				}
			});
			myform.addRule([{
				ele:"#name",
				datatype:"*1-100",
				ajaxurl:"__APP__?g=Admin&m=User&a=check_username&userid={$data.id}",
		        nullmsg:"请输入学校名称"
			},
			{
				ele:"#province_code",
				datatype:"*1-100",
		        nullmsg:"请选择地区"
			}]);
		});
		
		//获取城市列表
		function getCity() {
			$.post("__APP__?g=Index&m=Public&a=get_city",{province_code:$("#province_code").val()},function(data) {
				$("#city_code").empty();
				$("<option value=''>请选择</option>").appendTo("#city_code");
				if(data.status == "1") {
					var oResults = data.data;
	                for (var i = 0, len = oResults.length; i < len; i++) {
	                    $("<option value='"+oResults[i].code+"'>"+oResults[i].name+"</option>").appendTo("#city_code");
	                }
				} else {
					alert(data.info);
				}
			}, 'json');
		}
		
		//获取县区列表
		function getArea() {
			$.post("__APP__?g=Index&m=Public&a=get_area",{city_code:$("#city_code").val()},function(data) {
				$("#area_code").empty();
				$("<option>请选择</option>").appendTo("#area_code");
				if(data.status == "1") {
					var oResults = data.data;
	                for (var i = 0, len = oResults.length; i < len; i++) {
	                    $("<option value='"+oResults[i].code+"'>"+oResults[i].name+"</option>").appendTo("#area_code");
	                }
				} else {
					alert(data.info);
				}
			}, 'json');
		}
	</script>
</block>
<!-- 当前位置 -->

<block name="breadcrumb">
    <div class="page-header pull-left">
        <div class="page-title">修改学校</div>
    </div>
    <ol class="breadcrumb page-breadcrumb pull-left">
        <li><i class="fa fa-home"></i>&nbsp;<a href="__APP__?g=Admin">首页</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
        <li><a href="#">基础数据</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
        <li class="active">学校管理</li>
    </ol>
</block>

<!-- 网页主内容区 -->
<block name="main_content">
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-blue">
				<div class="panel-heading">修改学校</div>
				<div class="panel-body pan">
					<form id="myform" name="myform" action="__APP__?g={:GROUP_NAME}&m={:MODULE_NAME}&a=update" method="post" class="form-horizontal form-seperated">
						<div class="form-body"> 
							<div class="form-group">
								<label for="code" class="col-md-2 control-label">学校代码</label>
								<div class="col-md-7">
									<input type="text" id="code" name="code" value="{$data.code}" class="form-control" />
								</div>
							</div>
							<div class="form-group">
								<label for="name" class="col-md-2 control-label">学校名称<span class='require'>*</span></label>
								<div class="col-md-7">
									<input type="text" id="name" name="name" value="{$data.name}" class="form-control" />
								</div>
							</div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label" for="phone">所属地区<span class='require'>*</span></label>
								<div class="col-sm-7">
									<div class="row">
										<div class="col-sm-4">
											<select id="province_code" name="province_code" class="form-control" onChange="getCity()">
												<option value="">请选择</option>
												<volist name="province_list" id="vo">
													<option value="{$vo.code}" <eq name="province_code" value="$vo.code">selected</eq>>{$vo.name}</option>
												</volist>
											</select>
										</div>
										<div class="col-sm-4">
											<select id="city_code" name="city_code" class="form-control" onChange="getArea()">
												<option value="">请选择</option>
												<volist name="city_list" id="vo">
													<option value="{$vo.code}" <eq name="city_code" value="$vo.code">selected</eq>>{$vo.name}</option>
												</volist>
											</select>
										</div>
										<div class="col-sm-4">
											<select id="area_code" name="area_code" class="form-control">
												<option value="">请选择</option>
												<volist name="area_list" id="vo">
													<option value="{$vo.code}" <eq name="data.area_code" value="$vo.code">selected</eq>>{$vo.name}</option>
												</volist>	
											</select>
										</div>
									</div>
								</div>
							</div>
							
						</div>
						<div class="form-actions text-left">
							<div class="col-md-offset-2 col-md-7">
								<input type="hidden" name="id" value="{$data.id}" />
								<button type="submit" class="btn btn-primary">提交</button>&nbsp;&nbsp;
								<button type="button" class="btn btn-green" onclick="history.go(-1);">取消</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</block>
